package com.wsdcd.zlg.sb.core.interceptor;

import com.wsdcd.zlg.sb.core.constant.Constant;
import com.wsdcd.zlg.sb.model.entity.User;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class AuthInterceptor extends HandlerInterceptorAdapter {
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
////        HandlerMethod handlerMethod = (HandlerMethod) handler;
//        // 获取请求需要执行的方法名
////        String methodName = handlerMethod.getMethod().getName();
//        // 判断当前请求是否和登录操作相关
//        HttpSession session = request.getSession(true);
//        User loginUser = (User) session.getAttribute(Constant.LOGIN_USER);
//        if (loginUser == null) {
//            response.sendRedirect(request.getContextPath() + "/");
//            // 终止后续请求
//            return false;
//        }
//        // 放行
//        return super.preHandle(request, response, handler);
//    }
}
